package cpgears.helpers {
	import asunit.framework.TestCase;
	import flash.display.DisplayObjectContainer;
	import flash.display.MovieClip;
	
	/**
	 * ...
	 * @author Whyves
	 */
	public class CaptivateHelperTest extends TestCase{
		
		public function CaptivateHelperTest(testMethod:String = null) {
			super(testMethod);
		}
		
		//---------------------------------------------------------------------
		//  Add external interface
		//---------------------------------------------------------------------
		public function testAddExternalInterfaceFails():void {
			assertFalse(CaptivateHelper.addExternalInterface("myTestFunction", function ():void {}));
		}
		
		
		//---------------------------------------------------------------------
		//  Find Parent by name
		//---------------------------------------------------------------------
		public function testFindParentByName():void {
			var grandParent:DisplayObjectContainer = new MovieClip();
			grandParent.name = "grandParent";
			var parent:DisplayObjectContainer = new MovieClip();
			parent.name = "parent";
			var son:DisplayObjectContainer = new MovieClip();
			son.name = "son";
			
			parent.addChild(son);
			grandParent.addChild(parent);
			
			assertSame("Should have returned 'grandParent'.", grandParent, DisplayObjectUtil.findParentByName(son, grandParent.name));
		}
		
		public function testFindParentByNameNoResult():void {
			var grandParent:DisplayObjectContainer = new MovieClip();
			grandParent.name = "grandParent";
			var parent:DisplayObjectContainer = new MovieClip();
			parent.name = "parent";
			var son:DisplayObjectContainer = new MovieClip();
			son.name = "son";
			
			parent.addChild(son);
			grandParent.addChild(parent);
			
			assertNull("Should have returned 'null' since no parent has the name 'dummy'.", DisplayObjectUtil.findParentByName(son, "dummy"));
		}
	}
}